Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
@oclif/parser
Advanced tools
@oclif/parser is a command-line argument parser designed for use with the Oclif framework. It helps in parsing command-line arguments, flags, and options in a structured and efficient manner.
Parsing Arguments
This feature allows you to parse positional arguments from the command line. The code sample demonstrates how to define and parse two positional arguments.
const { parse } = require('@oclif/parser');
const argv = ['arg1', 'arg2'];
const options = { args: [{ name: 'firstArg' }, { name: 'secondArg' }] };
const result = parse(argv, options);
console.log(result.args); // { firstArg: 'arg1', secondArg: 'arg2' }
Parsing Flags
This feature allows you to parse flags from the command line. The code sample demonstrates how to define and parse two string flags.
const { parse } = require('@oclif/parser');
const argv = ['--flag1', 'value1', '--flag2', 'value2'];
const options = { flags: { flag1: { type: 'string' }, flag2: { type: 'string' } } };
const result = parse(argv, options);
console.log(result.flags); // { flag1: 'value1', flag2: 'value2' }
Parsing Boolean Flags
This feature allows you to parse boolean flags from the command line. The code sample demonstrates how to define and parse two boolean flags.
const { parse } = require('@oclif/parser');
const argv = ['--flag1', '--no-flag2'];
const options = { flags: { flag1: { type: 'boolean' }, flag2: { type: 'boolean' } } };
const result = parse(argv, options);
console.log(result.flags); // { flag1: true, flag2: false }
Parsing Options with Default Values
This feature allows you to define default values for flags. The code sample demonstrates how to set and retrieve a default value for a flag.
const { parse } = require('@oclif/parser');
const argv = [];
const options = { flags: { flag1: { type: 'string', default: 'defaultValue' } } };
const result = parse(argv, options);
console.log(result.flags); // { flag1: 'defaultValue' }
Yargs is a popular command-line argument parser that provides a rich set of features for parsing arguments, flags, and options. It offers a more extensive API compared to @oclif/parser and is widely used in the Node.js community.
Commander is another widely-used command-line argument parser that provides a simple and intuitive API for defining commands, arguments, and options. It is known for its ease of use and flexibility, making it a good alternative to @oclif/parser.
Minimist is a lightweight command-line argument parser that focuses on simplicity and minimalism. It is suitable for projects that require basic argument parsing without the overhead of more feature-rich libraries like @oclif/parser.
This library has been replaced by @oclif/core and is now in maintenance mode. We will only consider PRs that address security concerns.
arg and flag parser for oclif
CLI flag parser.
Usage:
const CLI = require('cli-flags')
const {flags, args} = CLI.parse({
flags: {
'output-file': CLI.flags.string({char: 'o'}),
force: CLI.flags.boolean({char: 'f'})
},
args: [
{name: 'input', required: true}
]
})
if (flags.force) {
console.log('--force was set')
}
if (flags['output-file']) {
console.log(`output file is: ${flags['output-file']}`)
}
console.log(`input arg: ${args.input}`)
// $ node example.js -f myinput --output-file=myexample.txt
// --force was set
// output file is: myexample.txt
// input arg: myinput
FAQs
arg and flag parser for oclif
The npm package @oclif/parser receives a total of 462,112 weekly downloads. As such, @oclif/parser popularity was classified as popular.
We found that @oclif/parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.